/*
 * @Author: 噜噜雯雯 2199987619@qq.com
 * @Date: 2025-05-28 11:29:08
 * @LastEditors: 噜噜雯雯 2199987619@qq.com
 * @LastEditTime: 2025-06-18 09:55:25
 * @FilePath: \linePatrol\vue-element-plus-admin\src\api\linePatrol\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import service from '@/axios/http'
import {
  GetPlanGroupType,
  RoleType,
  ParameterListType,
  XunLineAreaType,
  EventTypeListType,
  AddEventType,
  EditEventType
} from './type'
import { TableIResponse, ListIResponse } from '@/utils/Api'

export class BasicManageApi {
  //查询巡线参数列表
  async ParameterList(params: GetPlanGroupType): Promise<TableIResponse<ParameterListType[]>> {
    const result = (await service.get('/api/patrol/parameter/list', { params })) as unknown as any
    return result
  }
  //删除巡检计划列表
  async DeletParameter(ids: string): Promise<boolean> {
    const result = (await service.delete(`/api/patrol/parameter/${ids}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //获取巡线参数详细信息
  async GetParameterIdList(id: string): Promise<RoleType> {
    const result = (await service.get(`/api/patrol/parameter/${id}`)) as unknown as any
    return result
  }

  //新增巡线参数
  async AddParameterData(data: ParameterListType): Promise<boolean> {
    const result = (await service.post('/api/patrol/parameter', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改巡线参数
  async EditParameterData(data: ParameterListType): Promise<boolean> {
    const result = (await service.put('/api/patrol/parameter', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //查询巡线片区列表
  async GetXunLineAreaList(params: any): Promise<TableIResponse<XunLineAreaType[]>> {
    const result = (await service.get('/api/patrol/xunlineArea/list', { params })) as unknown as any
    return result
  }
  //删除巡检片区列表
  async DeleXunLineArea(ids: string): Promise<boolean> {
    const result = (await service.delete(`/api/patrol/xunlineArea/${ids}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //新增巡检片区列表
  async AddXunLineArea(data: XunLineAreaType): Promise<boolean> {
    const result = (await service.post('/api/patrol/xunlineArea', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改巡线片区信息
  async EditXunLineArea(data: XunLineAreaType): Promise<boolean> {
    const result = (await service.put('/api/patrol/xunlineArea', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //查询设施类型列表
  async GetEventTypeList(params: GetPlanGroupType): Promise<ListIResponse<EventTypeListType[]>> {
    const result = (await service.get('/api/patrol/eventType/list', { params })) as unknown as any
    return result
  }
  //删除设施类型列表
  async DeleEventType(id: string): Promise<boolean> {
    const result = (await service.delete(`/api/patrol/eventType/${id}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //新增巡检片区列表
  async AddEventType(data: AddEventType): Promise<boolean> {
    const result = (await service.post('/api/patrol/eventType', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改巡线片区信息
  async EditEventType(data: EditEventType): Promise<boolean> {
    const result = (await service.put('/api/patrol/eventType', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
}
export default new BasicManageApi()
